package com.xiaohei.rabbitmq.two;


import com.rabbitmq.client.Channel;
import com.xiaohei.rabbitmq.utils.RabbitmqUtils;

import java.util.Scanner;

/**
 * @Description: 生产者发送大量消息
 * @Author: 王希辰
 * @Date: 2022/3/16 16:51
 */
public class Task01 {
    //队列名称
    public  static  final String QUEUE_NAME="hello";

    public static void main(String[] args) throws Exception {
        //发送大量消息
        Channel channel= RabbitmqUtils.getChannel();
        //生成队列
        channel.queueDeclare(QUEUE_NAME,true,false,false,null);
        //从控制台接收消息
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNext()){
            String m = scanner.next();
            channel.basicPublish("",QUEUE_NAME,null,m.getBytes());
            System.out.println("发送消息完成："+m);
        }
    }

}
